import 'package:flutter/material.dart';

import 'common_page.dart';

//insert multi routes to navigator on navigator initialized via `onGenerateInitialRoutes`
class TabC extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Navigator(
      initialRoute: '/A/B/C',
      onGenerateRoute: onNaviCGenerateRoute,
      onGenerateInitialRoutes: (state, routeName) {
        List<String> routeNames = [];
        routeNames.add('/');
        routeNames.addAll(routeName.substring(1).split('/'));
        final routes = routeNames.map((routeName) {
          final routeSettings = RouteSettings(name: routeName);
          return MaterialPageRoute(
              builder: (context) => CommonPage(
                    settings: routeSettings,
                  ),
              settings: routeSettings);
        }).toList();
        return routes;
      },
    );
  }
}
